<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>AMBHAS: /home/tomer/svn/ambhas/ambhas/gw.py Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">AMBHAS
   
   </div>
   
  </td>
  
  
  
   
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('gw_8py.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">gw.py</div>  </div>
</div><!--header-->
<div class="contents">
<a href="gw_8py.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="namespaceambhas_1_1gw.html">00001</a> <span class="comment"># -*- coding: utf-8 -*-</span>
<a name="l00002"></a>00002 <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00003"></a>00003 <span class="stringliteral">Created on Wed Nov 16 14:25:50 2011</span>
<a name="l00004"></a>00004 <span class="stringliteral"></span>
<a name="l00005"></a>00005 <span class="stringliteral">@author: Sat Kumar Tomer</span>
<a name="l00006"></a>00006 <span class="stringliteral">@website: www.ambhas.com</span>
<a name="l00007"></a>00007 <span class="stringliteral">@email: satkumartomer@gmail.com</span>
<a name="l00008"></a>00008 <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00009"></a>00009 <span class="keyword">from</span> __future__ <span class="keyword">import</span> division
<a name="l00010"></a>00010 <span class="keyword">import</span> numpy <span class="keyword">as</span> np
<a name="l00011"></a>00011 <span class="keyword">from</span> ambhas.errlib <span class="keyword">import</span> L
<a name="l00012"></a>00012 <span class="keyword">from</span> osgeo <span class="keyword">import</span> gdal
<a name="l00013"></a>00013 <span class="keyword">from</span> osgeo.gdalconst <span class="keyword">import</span> *
<a name="l00014"></a>00014 <span class="keyword">from</span> ambhas.xls <span class="keyword">import</span> xlsread
<a name="l00015"></a>00015 
<a name="l00016"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html">00016</a> <span class="keyword">class </span><a class="code" href="classambhas_1_1gw_1_1GW__1D.html">GW_1D</a>():
<a name="l00017"></a>00017     <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00018"></a>00018 <span class="stringliteral">    This class perform the groundwater modelling</span>
<a name="l00019"></a>00019 <span class="stringliteral">    &quot;&quot;&quot;</span>
<a name="l00020"></a>00020     
<a name="l00021"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a46c209a71ce957384c4640348105b61c">00021</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a46c209a71ce957384c4640348105b61c">__init__</a>(self, R, Dnet=0):
<a name="l00022"></a>00022         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00023"></a>00023 <span class="stringliteral">        R: rainfall</span>
<a name="l00024"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a4dfc75ce4ec25f500a927f1dbed4c885">00024</a> <span class="stringliteral">        Dnet: net groundwater draft</span>
<a name="l00025"></a>00025 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00026"></a>00026         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a4dfc75ce4ec25f500a927f1dbed4c885">R</a> = R
<a name="l00027"></a>00027         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#ac789c8452d212dbf9e7ff4f83e1391ba">Dnet</a> = Dnet
<a name="l00028"></a>00028         
<a name="l00029"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a464f9ec5c3ef51eda5f47030598140d7">00029</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a464f9ec5c3ef51eda5f47030598140d7">set_parameters</a>(self, F, G, r, hmin=0):
<a name="l00030"></a>00030         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00031"></a>00031 <span class="stringliteral">        F: model parameter</span>
<a name="l00032"></a>00032 <span class="stringliteral">        G: model parameter</span>
<a name="l00033"></a>00033 <span class="stringliteral">        r: recharge factor</span>
<a name="l00034"></a>00034 <span class="stringliteral">        hmin: groundwater level at which base flow ceases</span>
<a name="l00035"></a>00035 <span class="stringliteral">        </span>
<a name="l00036"></a>00036 <span class="stringliteral">        sy: specific yield</span>
<a name="l00037"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a59f1296700c08294b861d99f9dffd7d6">00037</a> <span class="stringliteral">        lam: decay constant</span>
<a name="l00038"></a>00038 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00039"></a>00039         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#ab8e7ff9fe2f13a6e5da7988bb0fdbb38">F</a> = F
<a name="l00040"></a>00040         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a0df1c47f6084ae5dddd5726c9723d00e">G</a> = G
<a name="l00041"></a>00041         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a091aea66a22a33518f69c00be7989cbf">r</a> = r
<a name="l00042"></a>00042         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a44631f52b408778c03b0e2fbcdbd3d03">hmin</a> = hmin
<a name="l00043"></a>00043         
<a name="l00044"></a>00044         <span class="comment">#self.lam = (1-F)**2/G</span>
<a name="l00045"></a>00045         <span class="comment">#self.sy = (1-F)/G</span>
<a name="l00046"></a>00046         
<a name="l00047"></a>00047         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a59f1296700c08294b861d99f9dffd7d6">sy</a> = F/G
<a name="l00048"></a>00048         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a1ef6c70f56b3a06b2220532c806ea931">lam</a> = (1-F)*self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a59f1296700c08294b861d99f9dffd7d6">sy</a>
<a name="l00049"></a>00049             
<a name="l00050"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a12bbf1fd415930991252cda5f50ff181">00050</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a12bbf1fd415930991252cda5f50ff181">run_model</a>(self, hini, t):
<a name="l00051"></a>00051         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00052"></a>00052 <span class="stringliteral">        hini: initial groundwater level</span>
<a name="l00053"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#aae1b66255c26dee8dbcc011bed8d4fc4">00053</a> <span class="stringliteral">        t: time</span>
<a name="l00054"></a>00054 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00055"></a>00055         u = self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a091aea66a22a33518f69c00be7989cbf">r</a>*self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a4dfc75ce4ec25f500a927f1dbed4c885">R</a>-self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#ac789c8452d212dbf9e7ff4f83e1391ba">Dnet</a> <span class="comment"># net input</span>
<a name="l00056"></a>00056         
<a name="l00057"></a>00057         h = np.empty(t+1) <span class="comment"># create empty array</span>
<a name="l00058"></a>00058         h[0] = hini  - self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a44631f52b408778c03b0e2fbcdbd3d03">hmin</a>       <span class="comment"># set the initial condition</span>
<a name="l00059"></a>00059                 
<a name="l00060"></a>00060         <span class="keywordflow">for</span> k <span class="keywordflow">in</span> range(t):
<a name="l00061"></a>00061             h[k+1] = self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#ab8e7ff9fe2f13a6e5da7988bb0fdbb38">F</a>*h[k] + self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a0df1c47f6084ae5dddd5726c9723d00e">G</a>*u[k]
<a name="l00062"></a>00062             
<a name="l00063"></a>00063             
<a name="l00064"></a>00064         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#aae1b66255c26dee8dbcc011bed8d4fc4">h</a> = h + self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a44631f52b408778c03b0e2fbcdbd3d03">hmin</a> <span class="comment"># simulated gw levels</span>
<a name="l00065"></a>00065         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#ac3bb540687b93a28b3c54bc6225e40c7">discharge</a> = u[:t] - self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a59f1296700c08294b861d99f9dffd7d6">sy</a>*np.diff(h) <span class="comment"># simulated discharge</span>
<a name="l00066"></a>00066         
<a name="l00067"></a>00067  
<a name="l00068"></a>00068     
<a name="l00069"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a89323d9b8a7886c132e705c284eaa898">00069</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a89323d9b8a7886c132e705c284eaa898">ens</a>(self, F_lim, G_lim, r_lim, hmin_lim, ens, hini, h_obs, t):
<a name="l00070"></a>00070         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00071"></a>00071 <span class="stringliteral">        generate ensemble based on ensemble of parameters</span>
<a name="l00072"></a>00072 <span class="stringliteral">        Input:</span>
<a name="l00073"></a>00073 <span class="stringliteral">            F: min and max of F</span>
<a name="l00074"></a>00074 <span class="stringliteral">            G: min and max of G</span>
<a name="l00075"></a>00075 <span class="stringliteral">            r: min and max of r</span>
<a name="l00076"></a>00076 <span class="stringliteral">            hmin: min and max of hmin</span>
<a name="l00077"></a>00077 <span class="stringliteral">            ens: no. of ensembles</span>
<a name="l00078"></a>00078 <span class="stringliteral">            hini: initial gw level</span>
<a name="l00079"></a><a class="code" href="classambhas_1_1gw_1_1GW__1D.html#ab87c2a517b4e9653888151a56dcfd98d">00079</a> <span class="stringliteral">            t: final time</span>
<a name="l00080"></a>00080 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00081"></a>00081         F_ens = F_lim[0] + (F_lim[1]-F_lim[0]) * np.random.rand(ens)
<a name="l00082"></a>00082         G_ens = G_lim[0] + (G_lim[1]-G_lim[0]) * np.random.rand(ens)
<a name="l00083"></a>00083         r_ens = r_lim[0] + (r_lim[1]-r_lim[0]) * np.random.rand(ens)
<a name="l00084"></a>00084         hmin_ens = hmin_lim[0] + (hmin_lim[1]-hmin_lim[0]) * np.random.rand(ens)
<a name="l00085"></a>00085 
<a name="l00086"></a>00086         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a809a35d304b8ad5a6c4c13b7d66fd5a8">F_ens</a> = F_ens
<a name="l00087"></a>00087         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a30a71222dac2977b9f81c8e593b0ccaf">G_ens</a> = G_ens
<a name="l00088"></a>00088         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#ab87c2a517b4e9653888151a56dcfd98d">r_ens</a> = r_ens
<a name="l00089"></a>00089         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a661b226acabfac3d0d19a1b6222f27b2">hmin_ens</a> = hmin_ens        
<a name="l00090"></a>00090         
<a name="l00091"></a>00091         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#adee0424b420f263ce049b5fd772c892f">L</a> = np.empty(ens)
<a name="l00092"></a>00092         <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(ens):
<a name="l00093"></a>00093             self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a464f9ec5c3ef51eda5f47030598140d7">set_parameters</a>(F_ens[i], G_ens[i], r_ens[i], hmin_ens[i])
<a name="l00094"></a>00094             self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a12bbf1fd415930991252cda5f50ff181">run_model</a>(hini, t)
<a name="l00095"></a>00095             self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#adee0424b420f263ce049b5fd772c892f">L</a>[i] = <a class="code" href="classambhas_1_1gw_1_1GW__1D.html#adee0424b420f263ce049b5fd772c892f">L</a>(self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#aae1b66255c26dee8dbcc011bed8d4fc4">h</a>, h_obs[:t+1])
<a name="l00096"></a>00096     
<a name="l00097"></a>00097         <span class="comment"># select best ensembles        </span>
<a name="l00098"></a>00098         ind = self.L.argmax()
<a name="l00099"></a>00099                 
<a name="l00100"></a>00100         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a464f9ec5c3ef51eda5f47030598140d7">set_parameters</a>(F_ens[ind], G_ens[ind], r_ens[ind], hmin_ens[ind])
<a name="l00101"></a>00101         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a12bbf1fd415930991252cda5f50ff181">run_model</a>(hini, t)
<a name="l00102"></a>00102         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a897d7e944239e6a050745b7183185ab7">best_h</a> = self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#aae1b66255c26dee8dbcc011bed8d4fc4">h</a>
<a name="l00103"></a>00103         self.<a class="code" href="classambhas_1_1gw_1_1GW__1D.html#a2ad08c1f6b788d5c2dfbcafc3226272a">best_ind</a> = ind
<a name="l00104"></a>00104   
<a name="l00105"></a>00105 
<a name="l00106"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html">00106</a> <span class="keyword">class </span><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html">GW_2D_yz</a>():
<a name="l00107"></a>00107     <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00108"></a>00108 <span class="stringliteral">    This class perform the groundwater modelling</span>
<a name="l00109"></a>00109 <span class="stringliteral">    &quot;&quot;&quot;</span>
<a name="l00110"></a>00110     
<a name="l00111"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a4ec7772e68ab4a364ace5cc587766d3b">00111</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a4ec7772e68ab4a364ace5cc587766d3b">__init__</a>(self, R, Dnet=0):
<a name="l00112"></a>00112         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00113"></a>00113 <span class="stringliteral">        R: rainfall</span>
<a name="l00114"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ad85f849bffb77eec711b07fd7026a501">00114</a> <span class="stringliteral">        Dnet: net groundwater draft</span>
<a name="l00115"></a>00115 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00116"></a>00116         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ad85f849bffb77eec711b07fd7026a501">R</a> = R
<a name="l00117"></a>00117         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a0b8c0a227ac31efb2e44f5b35f961a08">Dnet</a> = 0
<a name="l00118"></a>00118     
<a name="l00119"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a0eb94bb3ba29ea952244b86164bf38e9">00119</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a0eb94bb3ba29ea952244b86164bf38e9">set_parameters</a>(self, lam, sy, r, hmin=0):
<a name="l00120"></a>00120         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00121"></a>00121 <span class="stringliteral">        F: model parameter</span>
<a name="l00122"></a>00122 <span class="stringliteral">        G: model parameter</span>
<a name="l00123"></a>00123 <span class="stringliteral">        r: recharge factor</span>
<a name="l00124"></a>00124 <span class="stringliteral">        hmin: groundwater level at which based flow ceases</span>
<a name="l00125"></a>00125 <span class="stringliteral">        </span>
<a name="l00126"></a>00126 <span class="stringliteral">        sy: specific yield</span>
<a name="l00127"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a4ad2fe5fb7c9517ec45f54f25224843a">00127</a> <span class="stringliteral">        lam: decay constant</span>
<a name="l00128"></a>00128 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00129"></a>00129         <span class="keywordflow">if</span> len(lam) != len(sy):
<a name="l00130"></a>00130             <span class="keywordflow">raise</span> ValueError(<span class="stringliteral">&#39;The lenght of F and G should be same&#39;</span>)
<a name="l00131"></a>00131         
<a name="l00132"></a>00132         nlayer = len(lam) <span class="comment"># number of verticle profiles</span>
<a name="l00133"></a>00133         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a3b525accea1ab3e672f4ff055adfdd0c">nlayer</a> = nlayer
<a name="l00134"></a>00134         
<a name="l00135"></a>00135         F = np.zeros((nlayer, nlayer))
<a name="l00136"></a>00136         G = np.zeros(nlayer)
<a name="l00137"></a>00137         <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(nlayer):
<a name="l00138"></a>00138             F[i,i] = 1 - lam[i]/sy[i]
<a name="l00139"></a>00139             G[i] = lam[i]/sy[i]**2
<a name="l00140"></a>00140             <span class="keywordflow">if</span> i&gt;0:
<a name="l00141"></a>00141                 F[i, i-1] = lam[i-1]/sy[i]
<a name="l00142"></a>00142                 G[i] = -lam[i-1]/(sy[i-1]*sy[i]) + lam[i]/sy[i]**2
<a name="l00143"></a>00143         
<a name="l00144"></a>00144         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a4acc8e09f1a55ece7513255d2e12a8c6">F</a> = F
<a name="l00145"></a>00145         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a1e5a173d2dfa552ee2578c8982428526">G</a> = G
<a name="l00146"></a>00146         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a4ad2fe5fb7c9517ec45f54f25224843a">r</a> = r
<a name="l00147"></a>00147         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ab3fc0d0d6103e1ab5c2ea876dcf9c94f">hmin</a> = hmin
<a name="l00148"></a>00148         
<a name="l00149"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ad1a8ead0e5db230f3d6d2a3cb50c66eb">00149</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ad1a8ead0e5db230f3d6d2a3cb50c66eb">run_model</a>(self, hini, t):
<a name="l00150"></a>00150         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00151"></a>00151 <span class="stringliteral">        hini: initial groundwater level</span>
<a name="l00152"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a08feffc799a7c31aa33dbabb4a809a3c">00152</a> <span class="stringliteral">        t: time</span>
<a name="l00153"></a>00153 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00154"></a>00154         u = self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a4ad2fe5fb7c9517ec45f54f25224843a">r</a>*self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ad85f849bffb77eec711b07fd7026a501">R</a>-self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a0b8c0a227ac31efb2e44f5b35f961a08">Dnet</a> <span class="comment"># net input</span>
<a name="l00155"></a>00155         
<a name="l00156"></a>00156         h = np.empty((t+1, self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a3b525accea1ab3e672f4ff055adfdd0c">nlayer</a>)) <span class="comment"># create empty array</span>
<a name="l00157"></a>00157         h[0,:] = np.array(hini)  - self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ab3fc0d0d6103e1ab5c2ea876dcf9c94f">hmin</a>       <span class="comment"># set the initial condition</span>
<a name="l00158"></a>00158                 
<a name="l00159"></a>00159         <span class="keywordflow">for</span> k <span class="keywordflow">in</span> range(t):
<a name="l00160"></a>00160             h[k+1] = np.dot(self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a4acc8e09f1a55ece7513255d2e12a8c6">F</a>,h[k,:]) + self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a1e5a173d2dfa552ee2578c8982428526">G</a>*u[k]
<a name="l00161"></a>00161            
<a name="l00162"></a>00162         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a08feffc799a7c31aa33dbabb4a809a3c">h</a> = h + self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ab3fc0d0d6103e1ab5c2ea876dcf9c94f">hmin</a>
<a name="l00163"></a>00163 
<a name="l00164"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a7f83222bcbac257d9b32d5c09f80691b">00164</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a7f83222bcbac257d9b32d5c09f80691b">ens</a>(self, lam_lim, sy_lim, r_lim, hmin_lim, ens, hini, h_obs, t):
<a name="l00165"></a>00165         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00166"></a>00166 <span class="stringliteral">        generate ensemble based on ensemble of parameters</span>
<a name="l00167"></a>00167 <span class="stringliteral">        Input:</span>
<a name="l00168"></a>00168 <span class="stringliteral">            F: min and max of F</span>
<a name="l00169"></a>00169 <span class="stringliteral">            G: min and max of G</span>
<a name="l00170"></a>00170 <span class="stringliteral">            r: min and max of r</span>
<a name="l00171"></a>00171 <span class="stringliteral">            hmin: min and max of hmin</span>
<a name="l00172"></a>00172 <span class="stringliteral">            ens: no. of ensembles</span>
<a name="l00173"></a>00173 <span class="stringliteral">            hini: initial gw level</span>
<a name="l00174"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ab75cf9f7432e9504a6fa3fef3f72939c">00174</a> <span class="stringliteral">            t: final time</span>
<a name="l00175"></a>00175 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00176"></a>00176         lam_lim = np.array(lam_lim)
<a name="l00177"></a>00177         sy_lim = np.array(sy_lim)
<a name="l00178"></a>00178         r_lim = np.array(r_lim)
<a name="l00179"></a>00179         hmin_lim = np.array(hmin_lim)
<a name="l00180"></a>00180         
<a name="l00181"></a>00181         nlayer = lam_lim.shape[1]
<a name="l00182"></a>00182         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a3b525accea1ab3e672f4ff055adfdd0c">nlayer</a> = nlayer
<a name="l00183"></a>00183         
<a name="l00184"></a>00184         R_v = np.random.rand(ens,nlayer)
<a name="l00185"></a>00185         lam_ens = np.tile(lam_lim[0,:],(ens,1)) + \
<a name="l00186"></a>00186             (np.tile(lam_lim[1,:],(ens,1)) - np.tile(lam_lim[0,:],(ens,1)))* R_v
<a name="l00187"></a>00187         
<a name="l00188"></a>00188         R_v = np.random.rand(ens,nlayer)
<a name="l00189"></a>00189         sy_ens = np.tile(sy_lim[0,:],(ens,1)) + \
<a name="l00190"></a>00190             (np.tile(sy_lim[1,:],(ens,1)) - np.tile(sy_lim[0,:],(ens,1)))* R_v
<a name="l00191"></a>00191         
<a name="l00192"></a>00192         r_ens = r_lim[0] + (r_lim[1]-r_lim[0]) * np.random.rand(ens)
<a name="l00193"></a>00193         
<a name="l00194"></a>00194         hmin_ens = hmin_lim[0] + (hmin_lim[1]-hmin_lim[0]) * np.random.rand(ens)
<a name="l00195"></a>00195             
<a name="l00196"></a>00196         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a43551b2277755ef5faa23095cfa65bdf">lam_ens</a> = lam_ens
<a name="l00197"></a>00197         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ab75cf9f7432e9504a6fa3fef3f72939c">sy_ens</a> = sy_ens
<a name="l00198"></a>00198         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a82df05e80ea4c93a2420c209c3344e64">r_ens</a> = r_ens
<a name="l00199"></a>00199         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a7cf0561c269e33b4c3ee734022952082">hmin_ens</a> = hmin_ens
<a name="l00200"></a>00200         
<a name="l00201"></a>00201         eff = np.empty((ens, nlayer))
<a name="l00202"></a>00202         <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(ens):
<a name="l00203"></a>00203             self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a0eb94bb3ba29ea952244b86164bf38e9">set_parameters</a>(lam_ens[i], sy_ens[i], r_ens[i], hmin_ens[i])
<a name="l00204"></a>00204             self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ad1a8ead0e5db230f3d6d2a3cb50c66eb">run_model</a>(hini, t)
<a name="l00205"></a>00205             <span class="keywordflow">for</span> j <span class="keywordflow">in</span> range(nlayer):
<a name="l00206"></a>00206                 eff[i,j] = <a class="code" href="namespaceambhas_1_1errlib.html#a87bd160952d99f375f6db2e41e69d013">L</a>(self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a08feffc799a7c31aa33dbabb4a809a3c">h</a>[:,j], h_obs[:t+1,j])
<a name="l00207"></a>00207         
<a name="l00208"></a>00208         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a91b3e19fc42bdc2c9b1aab098f38b7eb">eff</a> = eff.mean(axis=1)
<a name="l00209"></a>00209         <span class="comment"># select best ensembles        </span>
<a name="l00210"></a>00210         ind = self.eff.argmax()
<a name="l00211"></a>00211                 
<a name="l00212"></a>00212         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a0eb94bb3ba29ea952244b86164bf38e9">set_parameters</a>(lam_ens[ind], sy_ens[ind], r_ens[ind], hmin_ens[ind])
<a name="l00213"></a>00213         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ad1a8ead0e5db230f3d6d2a3cb50c66eb">run_model</a>(hini, t)
<a name="l00214"></a>00214         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#ab6efcc4cc0bdc6140bd3d9bf9ad43ab9">best_h</a> = self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a08feffc799a7c31aa33dbabb4a809a3c">h</a>
<a name="l00215"></a>00215         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html#a3c877423eaec9a882c74f8bd836de1ee">best_ind</a> = ind
<a name="l00216"></a>00216 
<a name="l00217"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html">00217</a> <span class="keyword">class </span><a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html">GW_2D_xy</a>():
<a name="l00218"></a>00218     <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00219"></a>00219 <span class="stringliteral">    this class performs the 2 dimensinoal groundwater modelling in horizonal </span>
<a name="l00220"></a>00220 <span class="stringliteral">    plane using the 2 dimensional groundwater flow equation</span>
<a name="l00221"></a>00221 <span class="stringliteral">    &quot;&quot;&quot;</span>
<a name="l00222"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a621d9f07b56f57c4a7a2a86b02dcb70b">00222</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a621d9f07b56f57c4a7a2a86b02dcb70b">__init__</a>(self, watershed, hini, D, dt, dx, hmin, F, outlet):
<a name="l00223"></a>00223         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00224"></a>00224 <span class="stringliteral">        watershed: map of watershed in tiff format, 1 means inside watershed</span>
<a name="l00225"></a>00225 <span class="stringliteral">        hini: initial groundwater level</span>
<a name="l00226"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a3d8eaedb4b8d5693674f845f0bcb1a23">00226</a> <span class="stringliteral">        D:  T/Sy</span>
<a name="l00227"></a>00227 <span class="stringliteral">        &quot;&quot;&quot;</span>
<a name="l00228"></a>00228         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a3d8eaedb4b8d5693674f845f0bcb1a23">watershed</a> = watershed
<a name="l00229"></a>00229         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#aa95e46989b711acd21a342803486f4f9">hini</a> = hini
<a name="l00230"></a>00230         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a179613a333e3707acd5e0ed9f1e07d16">D</a> = D
<a name="l00231"></a>00231         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#ac84cc8ffa77bffa923ba1fc9db9211b3">dt</a> = dt
<a name="l00232"></a>00232         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a3e5aa7c6fd3be90ea458ee6fc0f00c07">dx</a> = dx
<a name="l00233"></a>00233         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a2ba4fb83a8d06637f32fa232625e6d85">hmin</a> = hmin
<a name="l00234"></a>00234         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a7897b5692ef057257542a8e80462098a">F</a> = F
<a name="l00235"></a>00235         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a68dc579de3774b3c12f8902d3ac6f078">outlet</a> = outlet
<a name="l00236"></a>00236         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#aa725bbc78a1022fcc8e4effeeecd770f">mac_cormack</a>()
<a name="l00237"></a>00237         
<a name="l00238"></a>00238         
<a name="l00239"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#aa725bbc78a1022fcc8e4effeeecd770f">00239</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#aa725bbc78a1022fcc8e4effeeecd770f">mac_cormack</a>(self):
<a name="l00240"></a>00240         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00241"></a><a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#ad6685a60175c97617ef81109115d1e87">00241</a> <span class="stringliteral">        this uses the mac cormack scheme</span>
<a name="l00242"></a>00242 <span class="stringliteral">        &quot;&quot;&quot;</span>        
<a name="l00243"></a>00243         h = self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#aa95e46989b711acd21a342803486f4f9">hini</a>
<a name="l00244"></a>00244         dt = self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#ac84cc8ffa77bffa923ba1fc9db9211b3">dt</a>
<a name="l00245"></a>00245         dx = self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a3e5aa7c6fd3be90ea458ee6fc0f00c07">dx</a>
<a name="l00246"></a>00246         hmin = self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a2ba4fb83a8d06637f32fa232625e6d85">hmin</a>
<a name="l00247"></a>00247         F = self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a7897b5692ef057257542a8e80462098a">F</a>
<a name="l00248"></a>00248         outlet = self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#a68dc579de3774b3c12f8902d3ac6f078">outlet</a>
<a name="l00249"></a>00249         n_outlet = watershed[outlet].sum()
<a name="l00250"></a>00250         discharge = F*(h[watershed].mean()-hmin)
<a name="l00251"></a>00251         
<a name="l00252"></a>00252         grid_D = D*dt/dx**2
<a name="l00253"></a>00253         hstar = np.zeros(h.shape)
<a name="l00254"></a>00254         <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(h.shape[0]):
<a name="l00255"></a>00255             <span class="keywordflow">for</span> j <span class="keywordflow">in</span> range(h.shape[1]):
<a name="l00256"></a>00256                 <span class="keywordflow">if</span> watershed[i,j]:
<a name="l00257"></a>00257                     d2h_dx2 = h[i+2,j] -2*h[i+1,j] + h[i,j]
<a name="l00258"></a>00258                     d2h_dy2 = h[i,j+2] -2*h[i,j+1] + h[i,j]
<a name="l00259"></a>00259                     <span class="keywordflow">if</span> watershed[i+1,j]*watershed[i+2,j]  == 0:
<a name="l00260"></a>00260                         d2h_dx2 = 0
<a name="l00261"></a>00261                     <span class="keywordflow">if</span> watershed[i,j+1]*watershed[i,j+2] == 0:
<a name="l00262"></a>00262                         d2h_dy2 = 0
<a name="l00263"></a>00263                     hstar[i,j] = h[i,j] + grid_D*(d2h_dx2+ d2h_dy2)
<a name="l00264"></a>00264         
<a name="l00265"></a>00265         hnew = np.zeros(h.shape)
<a name="l00266"></a>00266         <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(h.shape[0]):
<a name="l00267"></a>00267             <span class="keywordflow">for</span> j <span class="keywordflow">in</span> range(h.shape[1]):
<a name="l00268"></a>00268                 <span class="keywordflow">if</span> watershed[i,j]:
<a name="l00269"></a>00269                     d2h_dx2 = h[i-2,j] -2*hstar[i-1,j] + hstar[i,j]
<a name="l00270"></a>00270                     d2h_dy2 = h[i,j-2] -2*hstar[i,j-1] + hstar[i,j]
<a name="l00271"></a>00271                     <span class="keywordflow">if</span> watershed[i-1,j]*watershed[i-2,j] == 0:
<a name="l00272"></a>00272                         d2h_dx2 = 0
<a name="l00273"></a>00273                     <span class="keywordflow">if</span> watershed[i,j-1]*watershed[i,j-2] == 0:
<a name="l00274"></a>00274                         d2h_dy2 = 0
<a name="l00275"></a>00275                     hnew[i,j] = 0.5*(h[i,j]+hstar[i,j] + grid_D*(d2h_dx2+ d2h_dy2))
<a name="l00276"></a>00276                            
<a name="l00277"></a>00277         self.<a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html#ad6685a60175c97617ef81109115d1e87">hnew</a> = hnew        
<a name="l00278"></a>00278         
<a name="l00279"></a>00279 <span class="keywordflow">if</span> __name__ == <span class="stringliteral">&quot;__main__&quot;</span>:
<a name="l00280"></a>00280     <span class="keyword">from</span> scipy.interpolate <span class="keyword">import</span> Rbf
<a name="l00281"></a>00281     <span class="keyword">from</span> random <span class="keyword">import</span> sample
<a name="l00282"></a>00282     <span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt
<a name="l00283"></a>00283     
<a name="l00284"></a>00284     <span class="comment">################## horizontal 2d grounwater model ##############</span>
<a name="l00285"></a>00285     <span class="comment"># read the watershed in tiff format</span>
<a name="l00286"></a><a class="code" href="namespaceambhas_1_1gw.html#a56a24b796f070b2e769960320ec4a063">00286</a>     dataset = gdal.Open(<span class="stringliteral">&#39;/home/tomer/south_gundal/geospatial_data/watershed_500.tif&#39;</span>,GA_ReadOnly)
<a name="l00287"></a><a class="code" href="namespaceambhas_1_1gw.html#a08b91a1b6a8cd2d6e89642e4ae472069">00287</a>     watershed = dataset.GetRasterBand(1).ReadAsArray()
<a name="l00288"></a>00288     watershed[-2,:] = 0
<a name="l00289"></a><a class="code" href="namespaceambhas_1_1gw.html#aace14fc1bd8ae7553b45b8328e1e9484">00289</a>     GT = dataset.GetGeoTransform()
<a name="l00290"></a>00290     <span class="comment"># read the initial groundwater level data from xls file</span>
<a name="l00291"></a><a class="code" href="namespaceambhas_1_1gw.html#adc2f7ffff9c9902e91bace8f345626c7">00291</a>     fname = <span class="stringliteral">&#39;/home/tomer/south_gundal/gw_level.xls&#39;</span>    
<a name="l00292"></a><a class="code" href="namespaceambhas_1_1gw.html#a01a99875a568d605fc54137d2e18a78d">00292</a>     xls_file = <a class="code" href="classambhas_1_1xls_1_1xlsread.html">xlsread</a>(fname)
<a name="l00293"></a><a class="code" href="namespaceambhas_1_1gw.html#ad4fe7a9d4138dd7763e9c71d281a8b55">00293</a>     sample_id = sample(xrange(23908), 500)
<a name="l00294"></a><a class="code" href="namespaceambhas_1_1gw.html#a6d091bbca9071c647ffaf60cc2e2ae25">00294</a>     gw_x = xls_file.get_cells(<span class="stringliteral">&#39;A1:A23908&#39;</span>, <span class="stringliteral">&#39;dec2009&#39;</span>)[sample_id].flatten()
<a name="l00295"></a><a class="code" href="namespaceambhas_1_1gw.html#aeb588bcf754db8c080cc0336a5209f08">00295</a>     gw_y = xls_file.get_cells(<span class="stringliteral">&#39;B1:B23908&#39;</span>, <span class="stringliteral">&#39;dec2009&#39;</span>)[sample_id].flatten()
<a name="l00296"></a><a class="code" href="namespaceambhas_1_1gw.html#a095222eb5f5b3f3f12fd997b5833c98d">00296</a>     gw_ini = xls_file.get_cells(<span class="stringliteral">&#39;E1:E23908&#39;</span>, <span class="stringliteral">&#39;dec2009&#39;</span>)[sample_id].flatten()
<a name="l00297"></a>00297     <span class="comment"># convert the point value of groundwater levels into a map having the same </span>
<a name="l00298"></a>00298     <span class="comment">#extent and size as of watershed</span>
<a name="l00299"></a><a class="code" href="namespaceambhas_1_1gw.html#a0fd31d0014160662b8ef227fe3e11f5a">00299</a>     rbfi = Rbf(gw_x, gw_y, gw_ini, function=<span class="stringliteral">&#39;linear&#39;</span>)
<a name="l00300"></a><a class="code" href="namespaceambhas_1_1gw.html#a9bf4cf1c772eb3148af06d9390d26161">00300</a>     xi = np.linspace(GT[0]+GT[1]/2, GT[0]+GT[1]*(dataset.RasterXSize-0.5), 
<a name="l00301"></a>00301                         dataset.RasterXSize)
<a name="l00302"></a><a class="code" href="namespaceambhas_1_1gw.html#a5ce7afe257b6cad2074d026ac5839021">00302</a>     yi = np.linspace(GT[3]+GT[5]/2, GT[3]+GT[5]*(dataset.RasterYSize-0.5),
<a name="l00303"></a>00303                         dataset.RasterYSize)
<a name="l00304"></a>00304     XI, YI = np.meshgrid(xi,yi)
<a name="l00305"></a><a class="code" href="namespaceambhas_1_1gw.html#a8a85a9fecf0766f7531270207904bc8c">00305</a>     hini = <a class="code" href="namespaceambhas_1_1gw.html#a0fd31d0014160662b8ef227fe3e11f5a">rbfi</a>(XI, YI)
<a name="l00306"></a>00306 
<a name="l00307"></a>00307     <span class="comment">#run the model</span>
<a name="l00308"></a><a class="code" href="namespaceambhas_1_1gw.html#a3cb10796e2fdfc704af8fdb20d5de746">00308</a>     dt = 1
<a name="l00309"></a><a class="code" href="namespaceambhas_1_1gw.html#ac6553c40565d4dac04ff134f92e1f989">00309</a>     D = 20/0.008
<a name="l00310"></a><a class="code" href="namespaceambhas_1_1gw.html#a9fdc7750c241e1d0e77a672688e4f47e">00310</a>     dx = 500
<a name="l00311"></a><a class="code" href="namespaceambhas_1_1gw.html#a0082387272de15ac26b95c6552fa3ddd">00311</a>     hmin = 500
<a name="l00312"></a><a class="code" href="namespaceambhas_1_1gw.html#ab4936211ff8ac32ba6cfd506982ae01c">00312</a>     F = 0.999
<a name="l00313"></a><a class="code" href="namespaceambhas_1_1gw.html#a8f415f93ee375564628eb72368e88801">00313</a>     outlet = [[5],[43,44,45,46]]
<a name="l00314"></a><a class="code" href="namespaceambhas_1_1gw.html#a7e244d37567c44fc1e4a75a3bb153342">00314</a>     foo = <a class="code" href="classambhas_1_1gw_1_1GW__2D__xy.html">GW_2D_xy</a>(watershed, hini, D, dt, dx, hmin, F, outlet)
<a name="l00315"></a>00315     
<a name="l00316"></a>00316     <span class="keywordflow">print</span> hini[watershed==1].mean()
<a name="l00317"></a>00317     <span class="keywordflow">print</span> foo.hnew[watershed==1].mean()
<a name="l00318"></a>00318     
<a name="l00319"></a>00319     plt.imshow(foo.hnew, vmin=650)
<a name="l00320"></a>00320     plt.colorbar()
<a name="l00321"></a>00321     plt.show()
<a name="l00322"></a>00322     <span class="comment">############ lumped (1D) model ##################3</span>
<a name="l00323"></a>00323     <span class="comment"># forcing</span>
<a name="l00324"></a><a class="code" href="namespaceambhas_1_1gw.html#aef84666752a100584541636f815f8a41">00324</a>     R = np.random.rand(100)
<a name="l00325"></a>00325     foo = <a class="code" href="classambhas_1_1gw_1_1GW__1D.html">GW_1D</a>(R)
<a name="l00326"></a>00326     
<a name="l00327"></a>00327     <span class="comment"># parameter</span>
<a name="l00328"></a>00328     F = 0.8
<a name="l00329"></a><a class="code" href="namespaceambhas_1_1gw.html#a0d1804768cd8f0c8e003ae3ddbc1f676">00329</a>     G = 10
<a name="l00330"></a><a class="code" href="namespaceambhas_1_1gw.html#a8814430178731fe3b03e4d6c96314e46">00330</a>     r = 0.1
<a name="l00331"></a>00331     <span class="comment">#foo.set_parameters(F, G, r)</span>
<a name="l00332"></a>00332     
<a name="l00333"></a>00333     <span class="comment"># initial condition</span>
<a name="l00334"></a><a class="code" href="namespaceambhas_1_1gw.html#a4a2797bf87114603003a986be1c7be65">00334</a>     h_ini = 10
<a name="l00335"></a>00335     
<a name="l00336"></a>00336     <span class="comment"># run the model    </span>
<a name="l00337"></a>00337     <span class="comment">#foo.run_model(h_ini, 100)</span>
<a name="l00338"></a>00338     
<a name="l00339"></a>00339     <span class="comment"># get the simulated data</span>
<a name="l00340"></a>00340     <span class="comment">#h_sim = foo.h</span>
<a name="l00341"></a>00341     
<a name="l00342"></a>00342     <span class="comment"># ensemble</span>
<a name="l00343"></a><a class="code" href="namespaceambhas_1_1gw.html#a8e05e9ef26aac225372c538e4495e9ce">00343</a>     h_obs = np.random.rand(101)
<a name="l00344"></a>00344     foo.ens([0.5, 1.0], [1, 20], [0, 0.2], [50,70], 2, 20, h_obs, 10)
<a name="l00345"></a>00345     <span class="comment">#print(foo.L)</span>
<a name="l00346"></a>00346     
<a name="l00347"></a>00347     <span class="comment">################### hill slope groundwater modelling ######################</span>
<a name="l00348"></a>00348     foo = <a class="code" href="classambhas_1_1gw_1_1GW__2D__yz.html">GW_2D_yz</a>(R)
<a name="l00349"></a><a class="code" href="namespaceambhas_1_1gw.html#a3862ac1c9fbec52a9701e3acffbec23c">00349</a>     lam = [0.00008, 0.00009, 0.0001, 0.0002]
<a name="l00350"></a><a class="code" href="namespaceambhas_1_1gw.html#a8ac2c30c431265bf8f15428780e4a563">00350</a>     sy = [0.001, 0.001, 0.001, 0.001]
<a name="l00351"></a>00351     r = 0.2
<a name="l00352"></a>00352     foo.set_parameters(lam, sy, r)
<a name="l00353"></a>00353     hini = [10,7,5,3]
<a name="l00354"></a>00354     foo.run_model(hini, 50)
<a name="l00355"></a>00355     
<a name="l00356"></a><a class="code" href="namespaceambhas_1_1gw.html#ad3ff1f33468222eba69124c28c3bf73d">00356</a>     lam_lim = [[0.2, 0.3, 0.4, 0.5], [0.3, 0.4, 0.5, 0.6]]
<a name="l00357"></a><a class="code" href="namespaceambhas_1_1gw.html#a987a7e24f9e81dbffb63d8ab9a0d2290">00357</a>     sy_lim = [[0.2, 0.3, 0.4, 0.5], [0.3, 0.4, 0.5, 0.6]]
<a name="l00358"></a><a class="code" href="namespaceambhas_1_1gw.html#ac73a51353c96901c66ec5649b757d55a">00358</a>     r_lim = [0.2,0.3]
<a name="l00359"></a><a class="code" href="namespaceambhas_1_1gw.html#a9decaeca428bb12361c029c70ddeb568">00359</a>     hmin_lim = [2,5]
<a name="l00360"></a><a class="code" href="namespaceambhas_1_1gw.html#ac4b65fd0825253c4f1ed68b3c3765a1f">00360</a>     ens = 10
<a name="l00361"></a><a class="code" href="namespaceambhas_1_1gw.html#a9fbd42ae38337e9845053c6a8ea919f6">00361</a>     t = 10
<a name="l00362"></a>00362     h_obs = np.random.rand(t+1,4)
<a name="l00363"></a>00363     foo.ens(lam_lim, sy_lim, r_lim, hmin_lim, ens, hini, h_obs, t)
<a name="l00364"></a>00364     
<a name="l00365"></a>00365     
<a name="l00366"></a>00366     
<a name="l00367"></a>00367     
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="gw_8py.html">gw.py</a>      </li>

    <li class="footer">Generated on Sat Jul 21 2012 12:26:08 for AMBHAS by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
